package xredis

import (
	"fmt"
	"gf-xb-api/internal/consts"

	"github.com/gogf/gf/v2/text/gstr"
)

// GTokenUserKey 获得gToken userKey
func GTokenUserKey(userId uint, deviceType int) string {
	return fmt.Sprintf("%s:%d:%d", consts.GTokenUserPrefix, deviceType, userId)
}

// GetUserIdFromGToken 从gToken中获得用户Id
func GetUserIdFromGToken(userKey string) string {
	arr := gstr.Split(userKey, ":")
	return arr[len(arr)-1]
}

// JwtTokenMatchKey ... Jwt令牌匹配键
func JwtTokenMatchKey(uuid string, deviceType int) string {
	return fmt.Sprintf("%s:%s:%d", consts.JWT_TOKEN_REDISKEY, uuid, deviceType)
}

// JwtTokenKey Jwt令牌键
func JwtTokenKey(uuid string, deviceType int) string {
	return fmt.Sprintf("%s:%s:%d", consts.JWT_TOKEN_REDISKEY, uuid, deviceType)
}

// JwtTokenBlackListKey Jwt令牌黑名单键
func JwtTokenBlackListKey(uuid string, deviceType int) string {
	return fmt.Sprintf("%s:%s:%d", consts.JWT_TOKEN_BLACKLIST_REDISKEY, uuid, deviceType)
}
